﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Infrastructure.Data.Client.SQLite
{
    public class ClientBuilderSqlService
    {
        /// <summary>
        /// image
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public static List<string> BuilderSql(IQueryable<Application.Admin.Dto.OpenSightAllPicDto> dto)
        {
            var sql = new List<string>();
            foreach (var item in dto)
            {
                sql.Add("insert into image values('" + item.ImageName + "'," + item.Id + ")");
            }
            return sql;
        }

        /// <summary>
        /// poi
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public static List<string> BuilderSql(IQueryable<Application.Admin.Dto.OpenSightWithOnePicDto> dto)
        {
            var sql = new List<string>();
            foreach (var item in dto)
            {
                var temp = "insert into poi values(";
                temp += item.Id;
                temp += ",'" + item.Name + "'";
                temp += "," + item.Lon;
                temp += "," + item.Lat;
                temp += "," + item.ClassId;
                temp += "," + item.AreaId;
                temp += ",'" + (item.SightPic != null ? item.SightPic.Name : "") + "'";
                temp += ",'" + item.Remark + "'";
                temp += "," + item.VouchNum;
                temp += ")";
                sql.Add(temp);
            }
            return sql;
        }

        /// <summary>
        /// line
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public static List<string> BuilderSql(IQueryable<Application.Admin.Dto.OpenTourDetailDto> dto)
        {
            var sql = new List<string>();
            foreach (var item in dto)
            {
                if (item.TourSight != null && item.TourSight.Count > 0)
                {
                    foreach (var sight in item.TourSight)
                    {
                        var temp = "insert into line values(";
                        temp += sight.SightId;
                        temp += ",'" + sight.Remark + "'";
                        temp += ",'" + sight.CustomDateTime + "'";
                        temp += ",'" + sight.SightPic + "'";
                        temp += "," + item.Id;
                        temp += ",'" + sight.SightName + "'";
                        temp += "," + sight.SightLat;
                        temp += "," + sight.SightLon;
                        temp += "," + sight.SightAreaId;
                        temp += "," + sight.Day;
                        temp += "," + sight.IsShowInMap;
                        temp += ")";
                        sql.Add(temp);
                    }
                }
            }
            return sql;
        }
    }
}